const Koa=require('koa'),
   router = require('koa-router')(),
   views=require('koa-views'),
   static=require('koa-static'),
  //封装异步promise方法,用原生的方式获取数据
   common=require('./common.js'),
   app=new Koa();

router.get('/',async (ctx)=>{
  await ctx.render('index');
});  　
router.post('/register', async (ctx) => {
  let data=await common.getPostData(ctx);
  ctx.body=data;
});

app
  .use(static(__dirname))
  .use(views('views',{extension:'ejs'}))
  .use(router.routes())
  .use(router.allowedMethods())
　.listen(3000);